
import bpy

import 全局控制.Node.节点和插座基类.bl_节点基类 as 基类

import engine.initLIB.load_dll as engineLib
import ctypes


'''class C_SceneNode_场景(基类.C_SN_基类):
	bl_dname = 'bl_node_场景帧'
	bl_label = '场景帧'
	m_场景 = bpy.props.PointerProperty(type=bpy.types.Scene)
	def init(self, context):
		super(C_SceneNode_场景, self).f_init(context)
		self.outputs.new('C_NodeSocket_i', name='场景ID')
	def draw_buttons(self, context, layout):
		layout.prop(self, 'm_场景')
	def update(self):
		pass
		#self.f_pushUpdate()
	def f_update(self, 是否向下传递=False, input插座=None):
		if self.m_场景 != None :
			self.outputs['场景ID'].f_setData(self.m_场景.m_场景ID)
		super(C_SceneNode_场景, self).f_update(是否向下传递, input插座)
		return False'''



def f_场景节点指向场景update(self, context):
	if self.m_场景 != None :
		data = (list(self.m_场景.name), self.m_场景.m_场景ID)
	else:
		data = ([], -1)
	engineLib.flexCAPI.f_node_传入BL数据(ctypes.c_wchar_p(self.id_data.name), ctypes.c_wchar_p(self.name), ctypes.py_object(data));

class C_Node_场景(基类.C_Node_基类):
	bl_dname = 'bl_node_场景帧'
	bl_label = '场景帧'

	m_场景 = bpy.props.PointerProperty(type=bpy.types.Scene, update=f_场景节点指向场景update)

	def init(self, context):
		super(C_Node_场景, self).f_init(context)
		self.outputs.new('C_Socket_场景', name='场景')
		self.outputs.new('C_Socket_I32', name='场景ID')

		self.f_toCPP()
		
	def draw_buttons(self, context, layout):
		layout.prop(self, 'm_场景')
	
	def update(self):
		pass
	def f_toCPP(self):
		engineLib.flexCAPI.f_创建场景节点(ctypes.c_wchar_p(self.id_data.name), ctypes.c_wchar_p(self.name), self.f_getPyObject());
		f_场景节点指向场景update(self, None)


class C_NODE_MENU_场景(bpy.types.Operator):
	bl_idname = 'node.global_node_scene'
	bl_label = '场景'
	bl_options = {'REGISTER', 'UNDO'}
	def execute(operator, context):
		bpy.ops.node.add_node(type='C_Node_场景', use_transform=True)
		return {'FINISHED'}



classes = (
	#C_SceneNode_场景,
	C_Node_场景,
	C_NODE_MENU_场景,
)

def register():
	for c in classes:
		bpy.utils.register_class(c)
		

def unregister():
	for c in classes:
		bpy.utils.unregister_class(c)



